<script type="text/html" template lay-done="layui.data.sendParams(d);">
    <div class="layui-form coreshop-form layui-form-pane" lay-filter="LAY-app-CoreCmsPromotion-grantForm" id="LAY-app-CoreCmsPromotion-grantForm">
        <input type="hidden" name="id" id="id" value="{{d.params.data.model.id}}" />

        <div class="layui-form-item">
            <label for="name" class="layui-form-label">优惠券名称</label>
            <div class="layui-input-inline layui-inline-8">
                <input class="layui-input" value="{{d.params.data.model.name || '' }}" disabled="disabled" />
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">分发方式</label>
            <div class="layui-input-inline layui-inline-7">
                <input type="radio" lay-filter="distributionMode" name="distributionMode" value="1" title="个人分发" checked="checked">
                <input type="radio" lay-filter="distributionMode" name="distributionMode" value="2" title="用户组分发">
            </div>
            <input type="hidden" id="signPointType" value="1">
        </div>

        <div class="layui-form-item distribution-user">
            <label for="sort" class="layui-form-label">用户信息</label>
            <div class="layui-input-inline  layui-inline-5">
                <input type="number" min="0" max="999999" name="userIdOrMobile" class="layui-input" lay-reqText="请输入数字" />
            </div>
            <div class="layui-form-mid layui-word-aux">请输入用户手机号码或者用户序列</div>
        </div>

        <div class="layui-form-item distribution-user-group">
            <label for="sort" class="layui-form-label">用户组</label>
            <div class="layui-input-inline  layui-inline-5">
                <select name="userGrade">
                    <option value="0" selected="selected">请选择</option>
                    {{# layui.each(d.params.data.userGrade, function(index, item){ }}
                    <option value="{{ item.id }}">{{ item.title }}</option>
                    {{# }); }}
                </select>
            </div>
            <div class="layui-form-mid layui-word-aux">请选择用户级别</div>
        </div>

        <div class="layui-form-item core-hidden">
            <div class="layui-input-block">
                <div class="layui-footer">
                    <input type="button" class="layui-btn" lay-submit lay-filter="LAY-app-CoreCmsPromotion-grantForm-submit" id="LAY-app-CoreCmsPromotion-grantForm-submit" value="确认分发">
                </div>
            </div>
        </div>
    </div>
</script>
<script>
    var debug = layui.setter.debug;
    layui.data.sendParams = function (d) {
        //开启调试情况下获取接口赋值数据
        if (debug) { console.log(d.params.data); }
        layui.use(['admin', 'form', 'laydate', 'upload', 'coreHelper', 'util', 'view'],
            function () {
                var $ = layui.$
                    , form = layui.form
                    , admin = layui.admin
                    , laydate = layui.laydate
                    , upload = layui.upload
                    , util = layui.util
                    , view = layui.view
                    , coreHelper = layui.coreHelper;


                //分发方式类型切换
                $(".distribution-user").show();
                $(".distribution-user-group").hide();

                form.on('radio(distributionMode)', function (data) {
                    if (data.value == 1) {
                        $(".distribution-user").show();
                        $(".distribution-user-group").hide();
                    } else {
                        $(".distribution-user").hide();
                        $(".distribution-user-group").show();
                    }
                });

                //重载form
                form.render(null, 'LAY-app-CoreCmsPromotion-grantForm');
            })
    };
</script>